package com.lzl.service;

import com.lzl.remote.ServicePriceClient;
import com.lzl.request.ForecastPriceDTO;
import com.lzl.responese.ForecastPriceResponese;
import com.lzl.responese.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * //TODO
 *
 * @author zhaolinlin
 * @description //TODO
 * @createTime 2022/8/15 23:13
 */
@Service
@Slf4j
public class ForecastPriceService {

    @Autowired
    ServicePriceClient servicePriceClient;

    public ResponseResult forecastPrice(String depLongitude,String depLatitude,String destLongitude,String destLatitude){

          log.info("出发地经度：" + depLongitude);
          log.info("出发地纬度：" + depLatitude);
          log.info("目的地经度：" + destLongitude);
          log.info("目的地纬度：" + destLongitude);

          log.info("调用估价服务，计算价格");
        ForecastPriceDTO forecastPriceDTO = new ForecastPriceDTO();
        forecastPriceDTO.setDepLongitude(depLongitude);
        forecastPriceDTO.setDepLatitude(depLatitude);
        forecastPriceDTO.setDestLongitude(destLongitude);
        forecastPriceDTO.setDestLatitude(destLatitude);
        ResponseResult<ForecastPriceResponese> forecast = servicePriceClient.forecast(forecastPriceDTO);
        double price = forecast.getData().getPrice();
        ForecastPriceResponese forecastPriceResponese = new ForecastPriceResponese();
        forecastPriceResponese.setPrice(price);

        return ResponseResult.success(forecastPriceResponese);
    }
}
